Skip to content

Add progressive depth-halving policy to Prover.advance_proof#4925

Closed
Stevengre wants to merge 1 commit into
runtimeverification:masterfrom
Stevengre:feat/per-depth-timeout-advance-proof
Closed

Add progressive depth-halving policy to Prover.advance_proof#4925
Stevengre wants to merge 1 commit into
runtimeverification:masterfrom
Stevengre:feat/per-depth-timeout-advance-proof

Conversation

@Stevengre

Copy link
Copy Markdown
Contributor

Closes #4924.

Factors kontrol's --per-depth-timeout mechanism out of tool-specific code and into a generic policy in Prover.advance_proof, as suggested by @ehildenb in this review comment.

What it does

advance_proof gains an optional per_depth_timeout: float | None = None. When set to a positive value (and the prover exposes a tunable step depth), each step_proof runs under a stall window of current_depth * per_depth_timeout seconds:

  • Step finishes in time → committed as usual.
  • Step exceeds its window → it is interrupted, the step depth is halved (floor of 1), and the same (uncommitted) node is retried at the shallower depth.
  • At the minimum depth and still stalling → the proof stops and stays pending.

This mirrors the kontrol behavior (--max-depth 1000 --per-depth-timeout 0.5 → 500s window, then 250s at depth 500, … down to depth 1) but as a reusable, in-process policy rather than a forked-subprocess kill loop.

How it stays generic

The policy lives entirely in the base Prover and is driven by three new hooks with safe no-op defaults:

  • get_step_depth() -> int | None — return None (default) to opt out of the policy entirely.
  • set_step_depth(depth) — no-op default.
  • interrupt() — abort an in-flight step_proof on another thread; no-op default.

APRProver overrides them to read/write execute_depth and to call kcfg_explore.interrupt(). Provers without a tunable depth are unaffected, and the code path when per_depth_timeout is unset is unchanged.

To actually abort an in-flight Kore RPC call, interrupt() is threaded through KCFGExploreCTermSymbolicKoreClientJsonRpcClientFacade/JsonRpcClientTransport. SingleSocketTransport.interrupt() shuts down the blocked socket (unblocking the reader thread) and reconnects so the prover stays usable; HttpTransport.interrupt() is a documented no-op.

Testing

  • New pyk/src/tests/unit/test_advance_proof.py (in-memory fake prover, no backend): covers halving-until-progress, stop-at-minimum-depth, no-halving-when-fast, and the disabled (no per_depth_timeout) path.
  • make -C pyk check passes (flake8, mypy, autoflake, isort, pydocstyle, black).
  • Full pyk unit suite passes.

Notes / follow-up

Client-side interrupt() reconnects to the same KoreServer (preserving added modules), but an abandoned computation may keep running server-side until it notices the dropped connection — unlike kontrol's full process-group kill. The shallower retry still proceeds correctly; a fully faithful server-restart variant would require the prover to own the server handle and is left as a follow-up.

CLI flag plumbing remains on the tool side (e.g. kontrol); this PR only provides the generic capability.

Implements runtimeverification#4924: factor kontrol's
`--per-depth-timeout` mechanism out of tool-specific code and into a
generic policy in `Prover.advance_proof`.

When `per_depth_timeout` is set, each step gets a stall window of
`current_depth * per_depth_timeout` seconds to commit. A step that
exceeds its window is interrupted, the step depth is halved (floor 1),
and the node is retried at the shallower depth; at the minimum depth the
proof stops and stays pending. Provers that do not expose a tunable
depth are unaffected, and the path without `per_depth_timeout` is
unchanged.

- Prover: generic no-op hooks get_step_depth/set_step_depth/interrupt
- APRProver: overrides them (execute_depth + kcfg_explore.interrupt)
- KCFGExplore/CTermSymbolic/KoreClient/JsonRpc*/Transport: interrupt()
  that force-unblocks an in-flight single-socket request and reconnects
- Unit tests covering halving, stop-at-floor, fast-path, and disabled
@Stevengre Stevengre marked this pull request as draft June 1, 2026 10:26
@Stevengre Stevengre closed this Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support progressive depth halving as a generic policy in Prover.advance_proof

1 participant